package com.cskaoyan.mall.product.controller;

import com.cskaoyan.mall.common.result.Result;
import com.cskaoyan.mall.product.dto.PlatformAttributeInfoDTO;
import com.cskaoyan.mall.product.dto.PlatformAttributeValueDTO;
import com.cskaoyan.mall.product.query.PlatformAttributeParam;
import com.cskaoyan.mall.product.service.PlatformAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
public class AdminPlatformController {
    @Autowired
    PlatformAttributeService platformAttributeService;

    @GetMapping("/attrInfoList/{firstCategoryId}/{secondCategoryId}/{thirdCategoryId}")
    public Result<List<PlatformAttributeInfoDTO>> attrInfoList(@PathVariable Long firstCategoryId, @PathVariable Long secondCategoryId, @PathVariable Long thirdCategoryId){
        List<PlatformAttributeInfoDTO> platformAttrInfoList = platformAttributeService.getPlatformAttrInfoList(firstCategoryId, secondCategoryId, thirdCategoryId);
        return Result.ok(platformAttrInfoList);
    }

    @PostMapping("/saveAttrInfo")
    public Result saveAttrInfo(@RequestBody PlatformAttributeParam platformAttributeParam){
        platformAttributeService.savePlatformAttrInfo(platformAttributeParam);
        return Result.ok();
    }

    @GetMapping("/getAttrValueList/{categoryId}")
    public Result<List<PlatformAttributeValueDTO>> getAttrValueList(@PathVariable Long categoryId){
        List<PlatformAttributeValueDTO> platformAttrInfo = platformAttributeService.getPlatformAttrInfoList(categoryId);
        return Result.ok(platformAttrInfo);
    }
}
